package com.univrz.flexmachine.scxml.model
{
	
	
	import flash.utils.Dictionary;
	
	
	
	public class HistoryNode extends StateNode implements ITransitionTarget
	{
	
		
		
		public static const DEEP		:String = "deep";
		public static const SHALLOW	:String = "shallow";
	
		public var type:String;
		
		
		
		
		public function HistoryNode( parent:StateNode, type:String )
		{
			super( parent );
			this.type = type;		
		}
		
		
		
		
		
		private var lastActiveStates:Dictionary = new Dictionary( );
		
		
		
		override protected function doExitBusiness( ):void
		{
			lastActiveStates = new Dictionary( );
			rememberActiveChildren( this );
		}
		
		
		
		private function rememberActiveChildren( parent:Node ):void
		{
			for each ( var child:Node in children )
			{
				if ( child.isActive )
				{
					lastActiveStates[ child ] = true;
					
					if ( type == DEEP )						// recursion
						rememberActiveChildren( child );					
				}
			}
		
		}
		
		
		
		
	}
	
}